//
//  ManagerDate.m
//  Test
//
//  Created by mac on 16/5/8.
//  Copyright © 2016年 mac. All rights reserved.
//

#import "ManagerDate.h"
#import "AFNetworking.h"
#import "MarketModel.h"
@implementation ManagerDate

-(void)requestData:(NSString *)url{
    AFHTTPSessionManager *sessionManager = [AFHTTPSessionManager manager];

    sessionManager.requestSerializer = [AFHTTPRequestSerializer serializer];
    sessionManager.responseSerializer = [AFJSONResponseSerializer serializer];
    sessionManager.responseSerializer.acceptableContentTypes =
    [NSSet setWithObjects:@"application/x-javascript",@"text/html", nil];
    
    [sessionManager GET:url parameters:nil progress:^(NSProgress * _Nonnull downloadProgress) {
        
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
        NSMutableArray *dataArray = [NSMutableArray array];
        for (NSDictionary *dic in responseObject) {
            MarketModel *marketModel = [MarketModel new];
            [marketModel setValuesForKeysWithDictionary:dic];
            [dataArray addObject:marketModel];
        }
        self.manager(dataArray);
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        
        NSLog(@"%@",error);
    }];
}
@end
